import Cat from '../cat'

/**
 * A provider for quick service task production
 */
export default function NyanPaletteProvider(palette, create, elementFactory) {

  this._create = create
  this._elementFactory = elementFactory

  palette.registerProvider(this)
}

NyanPaletteProvider.$inject = [
  'palette',
  'create',
  'elementFactory'
]

NyanPaletteProvider.prototype.getPaletteEntries = function() {

  var elementFactory = this._elementFactory,
    create = this._create

  function startCreate(event) {
    var serviceTaskShape = elementFactory.create(
      'shape', { type: 'bpmn:ScriptTask' }
    )

    create.start(event, serviceTaskShape)
  }

  function startCreate1(event) {
    var serviceTaskShape = elementFactory.create(
      'shape', { type: 'bpmn:BusinessRuleTask' }
    )

    create.start(event, serviceTaskShape)
  }

  function startCreate2(event) {
    var serviceTaskShape = elementFactory.create(
      'shape', { type: 'bpmn:ReceiveTask' }
    )

    create.start(event, serviceTaskShape)
  }

  return {
    'create-service-task': {
      group: 'activity',
      title: '判断',
      imageUrl: '/lc/img/image1.svg',
      action: {
        dragstart: startCreate2,
        click: startCreate2
      }
    },
    'create-service-task1': {
      group: 'activity',
      title: '文档',
      imageUrl: '/lc/img/image3.svg',
      width: 30,
      action: {
        dragstart: startCreate1,
        click: startCreate1
      }
    },
    'create-service-task2': {
      group: 'activity',
      title: '子流程',
      imageUrl: '/lc/img/image2.svg',
      action: {
        dragstart: startCreate,
        click: startCreate
      }
    }
  }
}
